/*     */ package com.cr.business;
/*     */ 
/*     */ import com.cr.business.domain.CrEvidenceInfo;
/*     */ import com.cr.business.domain.CrSourceEntrustment;
/*     */ import com.cr.business.service.ICrEvidenceInfoService;
/*     */ import com.cr.business.service.ICrSourceEntrustmentService;
/*     */ import com.cr.common.annotation.Log;
/*     */ import com.cr.common.core.controller.BaseController;
/*     */ import com.cr.common.core.domain.AjaxResult;
/*     */ import com.cr.common.core.page.TableDataInfo;
/*     */ import com.cr.common.enums.BusinessType;
/*     */ import org.apache.commons.lang3.StringUtils;
/*     */ import com.cr.common.utils.poi.ExcelUtil;
/*     */ import java.util.Arrays;
/*     */ import java.util.Date;
/*     */ import java.util.List;
/*     */ import java.util.stream.Collectors;
/*     */ import org.apache.shiro.authz.annotation.RequiresPermissions;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.ui.ModelMap;
/*     */ import org.springframework.web.bind.annotation.GetMapping;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.PostMapping;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ import org.springframework.web.bind.annotation.ResponseBody;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"/business/entrustment"})
/*     */ public class CrSourceEntrustmentController extends BaseController {
/*  39 */   private String prefix = "business/entrustment";
/*     */   
/*     */   @Autowired
/*     */   private ICrSourceEntrustmentService crSourceEntrustmentService;
/*     */   
/*     */   @Autowired
/*     */   private ICrEvidenceInfoService evidenceInfoService;
/*     */   
/*     */   @RequiresPermissions({"business:entrustment:view"})
/*     */   @GetMapping
/*     */   public String entrustment() {
/*  51 */     return this.prefix + "/entrustment";
/*     */   }
/*     */   
/*     */   @RequiresPermissions({"business:entrustment:list"})
/*     */   @PostMapping({"/list"})
/*     */   @ResponseBody
/*     */   public TableDataInfo list(CrSourceEntrustment crSourceEntrustment) {
/*  62 */     startPage();
/*  63 */     List<CrSourceEntrustment> list = this.crSourceEntrustmentService.selectCrSourceEntrustmentList(crSourceEntrustment);
/*  64 */     return getDataTable(list);
/*     */   }
/*     */   
/*     */   @RequiresPermissions({"business:entrustment:export"})
/*     */   @Log(title = "案源委托", businessType = BusinessType.EXPORT)
/*     */   @PostMapping({"/export"})
/*     */   @ResponseBody
/*     */   public AjaxResult export(CrSourceEntrustment crSourceEntrustment) {
/*  76 */     List<CrSourceEntrustment> list = this.crSourceEntrustmentService.selectCrSourceEntrustmentList(crSourceEntrustment);
/*  77 */     ExcelUtil<CrSourceEntrustment> util = new ExcelUtil(CrSourceEntrustment.class);
/*  78 */     return util.exportExcel(list, "案源委托数据");
/*     */   }
/*     */   
/*     */   @GetMapping({"/add"})
/*     */   public String add() {
/*  87 */     return this.prefix + "/add";
/*     */   }
/*     */   
/*     */   @RequiresPermissions({"business:entrustment:add"})
/*     */   @Log(title = "案源委托", businessType = BusinessType.INSERT)
/*     */   @PostMapping({"/add"})
/*     */   @ResponseBody
/*     */   public AjaxResult addSave(CrSourceEntrustment crSourceEntrustment) {
/*  99 */     int i = this.crSourceEntrustmentService.insertCrSourceEntrustment(crSourceEntrustment);
///* 100 */     if (i > 0 &&
///* 101 */       StringUtils.isNotEmpty(crSourceEntrustment.getFileUrl())) {
///* 102 */       List<String> fileList = Arrays.asList(crSourceEntrustment.getFileUrl().split(","));
///* 103 */       List<String> fileName = Arrays.asList(crSourceEntrustment.getFileName().split(","));
///* 104 */       for (int k = 0; k < fileList.size(); k++) {
///* 105 */         CrEvidenceInfo info = new CrEvidenceInfo();
///* 106 */         info.setClueId(crSourceEntrustment.getEntrustId());
///* 107 */         info.setImage(fileList.get(k));
///* 108 */         info.setType(Integer.valueOf(2));
///* 109 */         info.setName(fileName.get(k));
///* 110 */         this.evidenceInfoService.insertCrEvidenceInfo(info);
///*     */       }
///*     */     }
/* 114 */     return toAjax(i);
/*     */   }
/*     */   
/*     */   @GetMapping({"/edit/{entrustId}"})
/*     */   public String edit(@PathVariable("entrustId") Long entrustId, ModelMap mmap) {
/* 123 */     CrSourceEntrustment crSourceEntrustment = this.crSourceEntrustmentService.selectCrSourceEntrustmentByEntrustId(entrustId);
/* 124 */     CrEvidenceInfo evidenceInfo = new CrEvidenceInfo();
/* 125 */     evidenceInfo.setClueId(crSourceEntrustment.getEntrustId());
/* 126 */     //evidenceInfo.setType(Integer.valueOf(2));
/* 127 */     List<CrEvidenceInfo> infoList = this.evidenceInfoService.selectCrEvidenceInfoList(evidenceInfo);
///* 128 */     if (infoList.size() > 0) {
///* 129 */       String fileUrl = String.join(",", (Iterable<? extends CharSequence>)infoList.stream().map(v -> v.getImage()).collect(Collectors.toList()));
///* 130 */       crSourceEntrustment.setFileUrl(fileUrl);
///*     */     }
/* 133 */     mmap.put("crSourceEntrustment", crSourceEntrustment);
/* 134 */     mmap.put("fileList", infoList);
/* 135 */     return this.prefix + "/edit";
/*     */   }
/*     */   
/*     */   @RequiresPermissions({"business:entrustment:edit"})
/*     */   @Log(title = "案源委托", businessType = BusinessType.UPDATE)
/*     */   @PostMapping({"/edit"})
/*     */   @ResponseBody
/*     */   public AjaxResult editSave(CrSourceEntrustment crSourceEntrustment) {
/* 147 */     int i = this.crSourceEntrustmentService.updateCrSourceEntrustment(crSourceEntrustment);
///* 148 */     if (i > 0 &&
///* 149 */       StringUtils.isNotEmpty(crSourceEntrustment.getFileUrl())) {
///* 151 */       CrEvidenceInfo evidenceInfo = new CrEvidenceInfo();
///* 152 */       evidenceInfo.setClueId(crSourceEntrustment.getEntrustId());
///* 153 */       evidenceInfo.setType(Integer.valueOf(2));
///* 154 */       List<CrEvidenceInfo> infoList = this.evidenceInfoService.selectCrEvidenceInfoList(evidenceInfo);
///* 155 */       if (infoList.size() > 0) {
///* 156 */         List<String> ids = (List<String>)infoList.stream().map(v -> v.getEvidenceId().toString()).collect(Collectors.toList());
///* 157 */         this.evidenceInfoService.deleteCrEvidenceInfoByEvidenceIds(String.join(",", (Iterable)ids));
///*     */       }
///* 159 */       List<String> fileList = Arrays.asList(crSourceEntrustment.getFileUrl().split(","));
///* 160 */       List<String> fileName = Arrays.asList(crSourceEntrustment.getFileName().split(","));
///* 161 */       for (int k = 0; k < fileList.size(); k++) {
///* 162 */         CrEvidenceInfo info = new CrEvidenceInfo();
///* 163 */         info.setClueId(crSourceEntrustment.getEntrustId());
///* 164 */         info.setImage(fileList.get(k));
///* 165 */         info.setType(Integer.valueOf(2));
///* 166 */         info.setName(fileName.get(k));
///* 167 */         this.evidenceInfoService.insertCrEvidenceInfo(info);
///*     */       }
///*     */     }
/* 171 */     return toAjax(i);
/*     */   }
/*     */   
/*     */   @RequiresPermissions({"business:entrustment:remove"})
/*     */   @Log(title = "案源委托", businessType = BusinessType.DELETE)
/*     */   @PostMapping({"/remove"})
/*     */   @ResponseBody
/*     */   public AjaxResult remove(String ids) {
/* 183 */     return toAjax(this.crSourceEntrustmentService.deleteCrSourceEntrustmentByEntrustIds(ids));
/*     */   }
/*     */   
/*     */   @GetMapping({"/audit/{entrustId}"})
/*     */   public String audit(@PathVariable("entrustId") Long entrustId, ModelMap mmap) {
/* 192 */     CrSourceEntrustment crSourceEntrustment = this.crSourceEntrustmentService.selectCrSourceEntrustmentByEntrustId(entrustId);
/* 193 */     mmap.put("crSourceEntrustment", crSourceEntrustment);
/* 194 */     return this.prefix + "/audit";
/*     */   }
/*     */   
/*     */   @RequiresPermissions({"business:entrustment:edit"})
/*     */   @Log(title = "案源委托", businessType = BusinessType.UPDATE)
/*     */   @PostMapping({"/audit"})
/*     */   @ResponseBody
/*     */   public AjaxResult auditSave(CrSourceEntrustment crSourceEntrustment) {
/* 206 */     crSourceEntrustment.setApprovalTime(new Date());
/* 207 */     crSourceEntrustment.setPayTime(new Date());
/* 208 */     return toAjax(this.crSourceEntrustmentService.updateCrSourceEntrustment(crSourceEntrustment));
/*     */   }
/*     */   
/*     */   @GetMapping({"/info/{entrustId}"})
/*     */   public String info(@PathVariable("entrustId") Long entrustId, ModelMap mmap) {
/* 216 */     CrSourceEntrustment crSourceEntrustment = this.crSourceEntrustmentService.selectCrSourceEntrustmentByEntrustId(entrustId);
/* 218 */     CrEvidenceInfo evidenceInfo = new CrEvidenceInfo();
/* 219 */     evidenceInfo.setClueId(crSourceEntrustment.getEntrustId());
/* 220 */     //evidenceInfo.setType(Integer.valueOf(2));
/* 221 */     List<CrEvidenceInfo> infoList = this.evidenceInfoService.selectCrEvidenceInfoList(evidenceInfo);
///* 222 */     if (infoList.size() > 0) {
///* 223 */       String fileUrl = String.join(",", (Iterable<? extends CharSequence>)infoList.stream().map(v -> v.getImage()).collect(Collectors.toList()));
///* 224 */       crSourceEntrustment.setFileUrl(fileUrl);
///*     */     }
/* 226 */     mmap.put("fileList", infoList);
/* 228 */     mmap.put("crSourceEntrustment", crSourceEntrustment);
/* 229 */     return this.prefix + "/info";
/*     */   }
/*     */ }


/* Location:              D:\tmp\creditorRights-admin\BOOT-INF\classes\com.zip!\com\cr\business\CrSourceEntrustmentController.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */